package gui;

import java.awt.*;
import javax.swing.*;
import rulesControl.*;

/**
 * @author Wojciech Łopata
 *
 */

public class ByoYomiSelectionPanel extends JPanel
{
	private static final long serialVersionUID = -4624059769838456459L;
	private final JSpinner basicGameTimeSpinner;
	private final JSpinner periodNumberSpinner;
	private final JSpinner periodLengthSpinner;
	
	public ByoYomiSelectionPanel()
	{
		setLayout(new GridLayout(0, 2));
		
		add(new JLabel("Podstawowy czas gry: "));
		basicGameTimeSpinner = new JSpinner(new SpinnerNumberModel(20, 10, 120, 1));
		add(basicGameTimeSpinner);
		
		add(new JLabel("Ilość okresów: "));
		periodNumberSpinner = new JSpinner(new SpinnerNumberModel(30, 0, 60, 1));
		add(periodNumberSpinner);
		
		add(new JLabel("Długość okresu [s]: "));
		periodLengthSpinner = new JSpinner(new SpinnerNumberModel(30, 15, 120, 1));
		add(periodLengthSpinner);
	}
	
	public ByoYomi getCustomByoYomi()
	{
		return new StandardByoYomi(((Integer) basicGameTimeSpinner.getValue()) * 60 * 1000,
				((Integer) periodLengthSpinner.getValue()) * 1000,
				((Integer) periodNumberSpinner.getValue()));
	}
}
